package com.tally.server.enums;

/**
 * @Author: sy
 * @Date: 2020/12/11 22:21
 * @Description:
 */
public enum CostTypeEnum {
    EAT("EA","餐饮"),
    HOUSE("HO","住房"),
    COMMUNICATION("CO","通讯"),
    TRAFFIC("TR","交通"),
    DAILY("DA","日用"),
    EDUCATION("ED","教育"),
    CLOTHES("CL","服装"),
    SNACKS("SN","零食"),
    FRUITS("FR","水果"),
    MEDICAL("ME","医疗"),
    OTHERS("OT","其它"),
    ;

    private String code;
    private String desc;

    CostTypeEnum(String code,String desc){
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static String getDesc(String code) {
        CostTypeEnum[] costTypeEnums = CostTypeEnum.values();
        for (CostTypeEnum costTypeEnum: costTypeEnums) {
            if (costTypeEnum.getCode().equals(code)) {
                return costTypeEnum.getDesc();
            }
        }
        throw new IllegalArgumentException("No results");
    }
}
